<?php TPL::output('global/header_meta.tpl.htm'); ?>
<?php
	$nav=array(
		0=>array('url'=>'home','title'=>'动态','status'=>'Y','is_user'=>1,'icon'=>'icon icon-home'),
		1=>array('url'=>'column','title'=>'专栏','status'=>get_setting('enable_column'),'is_user'=>1,'icon'=>'icon icon-column'),
		2=>array('url'=>'explore','title'=>'发现','status'=>'Y','is_user'=>0,'icon'=>'icon icon-list'),
		3=>array('url'=>'topic','title'=>'话题','status'=>'Y','is_user'=>0,'icon'=>'icon icon-topic'),
		4=>array('url'=>'notifications','title'=>'通知','status'=>'Y','is_user'=>1,'icon'=>'icon icon-bell'),
		5=>array('url'=>'help','title'=>'帮助','status'=>get_setting('enable_help_center'),'is_user'=>0,'icon'=>'icon icon-bulb'),
	);
	if(!$this->user_id){	
		foreach($nav as $k=>$v){
			if($v['is_user']==1)
				unset($nav[$k]);
		}	
	}else{
		foreach($nav as $k=>$v){
			if($v['status']=='N')
				unset($nav[$k]);
		}	
	}
?>
<body>
	<div class="aw-top-menu-wrap">
		<div class="container">
			<!-- logo -->
			<div class="aw-logo hidden-xs">
				<a href="<?php echo base_url(); ?>"></a>
			</div>
			<!-- end logo -->
			<!-- 搜索框 -->
			<div class="aw-search-box  hidden-xs hidden-sm">
				<form class="navbar-search" action="search/" id="global_search_form" method="post">
					<input class="form-control search-query" type="text" value="<?php echo $this->keyword;?>" placeholder="<?php _e('搜索问题、话题或人'); ?>" autocomplete="off" name="q" id="aw-search-query" />
					<span title="<?php _e('搜索'); ?>" id="global_search_btns" onClick="$('#global_search_form').submit();"><i class="icon icon-search"></i></span>
					<div class="aw-dropdown">
						<div class="mod-body">
							<p class="title"><?php _e('输入关键字进行搜索'); ?></p>
							<ul class="aw-dropdown-list collapse"></ul>
							<p class="search"><span><?php _e('搜索'); ?>:</span><a onClick="$('#global_search_form').submit();"></a></p>
						</div>
						<div class="mod-footer">
							<a href="<?php if (get_setting('quick_publish') == 'Y' && $this->user_id) { ?>javascript:;<?php } else { ?>publish<?php } ?>" onClick="$('#header_publish').click();" class="pull-right btn btn-mini btn-success publish"><?php _e('发起问题'); ?></a>
						</div>
					</div>
				</form>
			</div>
			<!-- end 搜索框 -->
			<!-- 导航 -->
			<div class="aw-top-nav navbar">
				<div class="navbar-header">
				  <button  class="navbar-toggle pull-left">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				  </button>
				</div>
				<nav role="navigation" class="collapse navbar-collapse bs-navbar-collapse">
				  <ul class="nav navbar-nav">
				  	<?php
				  	 foreach(array_slice($nav,0,5) as $k=>$v):?>
				  		<?php if($v['is_user']==0 && $v['status']=='Y'):?>
							<li><a href="<?php echo $v['url'];?>/"<?php if ($_GET['app'] == $v['url'] ) { ?> class="active"<?php } ?>><i class="<?php echo $v['icon'];?>"></i> <?php _e($v['title']); ?></a></li>
						<?php elseif($v['is_user']==1 && $v['status']=='Y' && $this->user_id):?>
							<?php if($v['url']=='notifications'):?>
								<li>
									<a href="notifications/" class="<?php if ($_GET['app'] == 'notifications') { ?>active<?php } ?>"><i class="icon icon-bell"></i> <?php _e('通知'); ?></a>
									<span class="badge badge-important" style="display:none" id="notifications_unread"><?php echo $this->user_info['notification_unread']; ?></span>
									<div class="aw-dropdown pull-right hidden-xs">
										<div class="mod-body">
											<ul id="header_notification_list"></ul>
										</div>
										<div class="mod-footer">
											<a href="notifications/"><?php _e('查看全部'); ?></a>
										</div>
									</div>
								</li>
							<?php else:?>
							<li><a href="<?php echo $v['url'];?>/"<?php if ($_GET['app'] == $v['url'] ) { ?> class="active"<?php } ?>><i class="<?php echo $v['icon'];?>"></i> <?php _e($v['title']); ?></a></li>
							<?php endif;?>
						<?php endif;?>
				  	<?php endforeach;?>
<!-- 					<?php if ($this->user_id) { ?>
					<li><a href="home/"<?php if ($_GET['app'] == 'home') { ?> class="active"<?php } ?>><i class="icon icon-home"></i> <?php _e('动态'); ?></a></li>
					<?php } ?>
					<?php if ($this->user_id && get_setting('enable_column')=='Y') { ?>
					<li><a href="column/"<?php if ($_GET['app'] == 'column') { ?> class="active"<?php } ?>><i class="icon icon-column"></i> <?php _e('专栏'); ?></a></li>
					<?php } ?>
					<li><a href="<?php echo base_url(); ?>" class="<?php if (!$_GET['app'] OR $_GET['app'] == 'explore') { ?>active<?php } ?>"><i class="icon icon-list"></i> <?php _e('发现'); ?></a></li>
					<li><a href="topic/" <?php if ($_GET['app'] == 'topic') { ?>class="active"<?php } ?>><i class="icon icon-topic"></i> <?php _e('话题'); ?></a></li>
					<?php if ($this->user_id) { ?>
					<li>
						<a href="notifications/" class="<?php if ($_GET['app'] == 'notifications') { ?>active<?php } ?>"><i class="icon icon-bell"></i> <?php _e('通知'); ?></a>
						<span class="badge badge-important" style="display:none" id="notifications_unread"><?php echo $this->user_info['notification_unread']; ?></span>
						<div class="aw-dropdown pull-right hidden-xs">
							<div class="mod-body">
								<ul id="header_notification_list"></ul>
							</div>
							<div class="mod-footer">
								<a href="notifications/"><?php _e('查看全部'); ?></a>
							</div>
						</div>
					</li>
					<?php } ?> -->
					<!-- <?php if (get_setting('enable_help_center') == 'Y' && (!$this->user_id || get_setting('enable_column')=='N')) { ?><li><a href="help/"<?php if ($_GET['app'] == 'help') { ?> class="active"<?php } ?>><i class="icon icon-bulb"></i> <?php _e('帮助'); ?></a></li><?php } ?> -->
					<li>
						<a style="font-weight:bold;">· · ·</a>
						<div class="dropdown-list pull-right">
							<ul id="extensions-nav-list">
								<?php if (check_extension_package('ticket') && get_setting('ticket_enabled') == 'Y' && ($this->user_info['permission']['publish_ticket'] || $this->user_info['permission']['is_administortar'] || $this->user_info['permission']['is_service'])) { ?>
								<li><a href="ticket/"<?php if ($_GET['app'] == 'ticket') { ?> class="active"<?php } ?>><i class="icon icon-order"></i> <?php _e('工单'); ?></a></li>
								<?php } ?>
								<?php if (check_extension_package('project') && get_setting('project_enabled') == 'Y') { ?>
								<li><a href="project/"<?php if ($_GET['app'] == 'project') { ?> class="active"<?php } ?>><i class="icon icon-activity"></i> <?php _e('活动'); ?></a></li>
								<?php } ?>
				  	<?php foreach(array_slice($nav,5) as $k=>$v):?>
				  		<?php if($v['is_user']==0 && $v['status']=='Y'):?>
							<li><a href="<?php echo $v['url'];?>/"<?php if ($_GET['app'] == $v['url'] ) { ?> class="active"<?php } ?>><i class="<?php echo $v['icon'];?>"></i> <?php _e($v['title']); ?></a></li>
						<?php elseif($v['is_user']==1 && $v['status']=='Y' && $this->user_id):?>
							<li><a href="<?php echo $v['url'];?>/"<?php if ($_GET['app'] == $v['url'] ) { ?> class="active"<?php } ?>><i class="<?php echo $v['icon'];?>"></i> <?php _e($v['title']); ?></a></li>
						<?php endif;?>
				  	<?php endforeach;?>
								
							</ul>
						</div>
					</li>
				  </ul>
				</nav>
			</div>
			<!-- end 导航 -->
			<!-- 用户栏 -->
			<div class="aw-user-nav">
				<!-- 登陆&注册栏 -->
				<?php if ($this->user_id) { ?>
					<a href="people/<?php echo $this->user_info['url_token']; ?>" class="aw-user-nav-dropdown">
						<img alt="<?php echo $this->user_info['user_name']; ?>" src="<?php echo get_avatar_url($this->user_info['uid'], 'mid'); ?>" />
						<?php if ($this->user_info['inbox_unread'] != 0) {?>
							<span class="badge badge-important"><?php echo $this->user_info['inbox_unread']?></span>
						<?php } ?>

					</a>
					<div class="aw-dropdown dropdown-list pull-right">
						<ul class="aw-dropdown-list">
							<li><a href="inbox/"><i class="icon icon-inbox"></i> <?php _e('私信'); ?><span class="badge badge-important collapse" id="inbox_unread">0</span></a></li>
							<li class="hidden-xs"><a href="account/setting/profile/"><i class="icon icon-setting"></i> <?php _e('设置'); ?></a></li>
							<?php if ($this->user_info['permission']['is_administortar'] OR $this->user_info['permission']['is_moderator']) { ?>
							<li class="hidden-xs"><a href="admin/"><i class="icon icon-job"></i> <?php _e('管理'); ?></a></li>
							<?php } ?>
                            <li id="changeSkin"><a href="javascript:void(0);"><i class="icon icon-skin"></i> <?php _e('换肤'); ?></a></li>
                            <li><a href="account/logout/"><i class="icon icon-logout"></i> <?php _e('退出'); ?></a></li>
						</ul>
					</div>
                    <div class="aw-dropdown dropdown-list pull-right" id="skinList" style="left: 100%;top:200%;display: none">
                        <ul class="aw-dropdown-list">
                            <li><a href="account/change_skin/?type=common"><i class="icon icon-draft"></i> <?php _e('默认'); ?>&nbsp;&nbsp;<?php if($this->user_info['skin']=='common.css'){?>√<?php }?></a></li>
                            <li><a href="account/change_skin/?type=green"><i class="icon icon-draft"></i> <?php _e('绿色'); ?>&nbsp;&nbsp;<?php if($this->user_info['skin']=='green.css'){?>√<?php }?></a></li>
                            <li><a href="account/change_skin/?type=orange"><i class="icon icon-draft"></i> <?php _e('橙色'); ?>&nbsp;&nbsp;<?php if($this->user_info['skin']=='orange.css'){?>√<?php }?></a></li>
                        </ul>
                    </div>
				<?php } else { ?>
					<a class="login btn btn-normal btn-primary" href="account/login/"><?php _e('登录'); ?></a>
					<?php if (get_setting('register_type') == 'open') { ?><a class="register btn btn-normal btn-success" href="account/register/"><?php _e('注册'); ?></a><?php } ?>
				<?php } ?>
				<!-- end 登陆&注册栏 -->
			</div>
			<!-- end 用户栏 -->
			<!-- 发起 -->
			<?php if ($this->user_id) { ?>
			<div class="aw-publish-btn">

				<a id="header_publish" class="btn-primary" <?php if (get_setting('quick_publish') == 'Y' AND $this->user_id) { ?>href="publish/"<?php } else { ?>href="publish/<?php if ($_GET['category']) { ?>category_id-<?php echo intval($_GET['category']); ?>__<?php } ?><?php if ($this->topic_info) { ?>topic_title-<?php echo urlencode($this->topic_info['topic_title']); ?>__<?php } ?>"<?php } ?><?php if (get_setting('quick_publish') == 'Y' && $this->user_id) { ?> onclick="AWS.dialog('publish', {'category_enable':'<?php echo (get_setting('category_enable') == 'Y') ? '1' : '0'; ?>', 'category_id':'<?php echo intval($_GET['category']); ?>', 'topic_title':'<?php echo $this->topic_info['topic_title']; ?>'}); return false;"<?php } ?>><i class="icon icon-ask"></i><?php _e('发起'); ?></a>
				<div class="dropdown-list pull-right">
					<ul>
						<li>
							<form method="post" action="publish/">
								<?php if ($this->topic_info['topic_title']) { ?>
								<input type="hidden" value="<?php echo $this->topic_info['topic_title']; ?>" name="topics[]" />
								<?php } ?>
								<a onclick="$(this).parents('form').submit();"><?php _e('问题'); ?></a>
							</form>

						</li>
						<?php if ($this->user_info['permission']['publish_article']) { ?>
						<li>
							<form method="post" action="publish/article/">
								<?php if ($this->topic_info['topic_title']) { ?>
								<input type="hidden" value="<?php echo $this->topic_info['topic_title']; ?>" name="topics[]" />
								<?php } ?>
								<a onclick="$(this).parents('form').submit();"><?php _e('文章'); ?></a>
							</form>
						</li>
						<?php if(is_website()){?>
						<li>
							<form method="post" action="publish/suggest/">
								<?php if ($this->topic_info['topic_title']) { ?>
								<input type="hidden" value="<?php echo $this->topic_info['topic_title']; ?>" name="topics[]" />
								<?php } ?>
								<a onclick="$(this).parents('form').submit();"><?php _e('建议'); ?></a>
							</form>
						</li>
						<?php } ?>
						<?php } ?>
						<?php if (check_extension_package('ticket') && get_setting('ticket_enabled') == 'Y' && $this->user_info['permission']['publish_ticket']) { ?>
						<li><a href="ticket/publish/"><?php _e('工单'); ?></a></li>
						<?php } ?>
						<?php if (check_extension_package('project') && get_setting('project_enabled') == 'Y' && $this->user_info['permission']['publish_project']) { ?>
						<li><a href="project/publish/"><?php _e('活动'); ?></a></li>
						<?php } ?>
					</ul>
				</div>
			</div>
			<?php }?>
			<!-- end 发起 -->
		</div>
	</div>
	<?php if ($this->user_id AND $this->user_info['email'] AND !$this->user_info['valid_email'] AND get_setting('register_valid_type') != 'N') { ?>
	<div class="aw-email-verify">
		<div class="container text-center">
			<a onclick="AWS.ajax_request(G_BASE_URL + '/account/ajax/send_valid_mail/');"><?php _e('你的邮箱 %s 还未验证, 点击这里重新发送验证邮件', $this->user_info['email']); ?></a>
		</div>
	</div>
	<?php } ?>

    <script>
        $(function () {
            var $changeSkin = $("#changeSkin"), $skinList = $("#skinList");
            $changeSkin.mouseenter(function () {
                $skinList.stop(true,true).show();
            });
            $changeSkin.mouseleave(function (e) {
                $skinList.hide();
            });
            $skinList.mouseover(function () {
                $(this).stop(true,true).show();
            });
            $skinList.mouseleave(function (e) {
                $(this).hide();
            })
        })
    </script>